<template>
  <div class="table_container">
    <el-table
      :data="infoData"
      ref="tableNode"
      :max-height="tableCascadeHeight"
      v-loading="isLoading"
      border
      stripe
      tooltip-effect="dark">
      <mes-column :key="index" v-for="(column, index) in columns" :column="column"></mes-column>
      <el-table-column
        prop="templateName"
        :resizable="false"
        label="操作"
        width="90"
        show-overflow-tooltip
        fixed="right"
        align="center">
        <template slot-scope="scope">
          <span class="jump_item"
                v-if="authorityJudge(scope.row)"
                :class="{is_disabled: !scope.row.parameterRecordId}"
                @click="showRecord(scope.row)">参数记录</span>
          <span class="jump_item is_disabled"
                v-else>暂无权限</span>
        </template>
      </el-table-column>
    </el-table>
    <see-records ref="SeeRecords"></see-records>
  </div>
</template>

<script>
import workstageColumns from './workstageColumns'
import {SeeRecords} from '../../../../../components/Template'

export default {
  name: 'WorkstageList',
  props: {
    infoData: {
      type: Array,
      default() {
        return []
      }
    }
  },
  components: {
    SeeRecords
  },
  data() {
    return {
      columns: workstageColumns,
      isLoading: false
    }
  },
  computed: {
    userInfo() {
      return this.$store.state.userInfo || {}
    },
  },
  methods: {
    // 显示参数记录
    showRecord(row) {
      if (row && row.parameterRecordId) this.$refs.SeeRecords.openDialog(row.id)
    },
    // 权限判断
    authorityJudge(row) {
      switch (this.userInfo.secretLevel) {
        case 'ID_PSL_Confidential':
          return true
        case 'ID_PSL_Secret':
          return row.paramRecordSecretLevelId === 'ID_PSL_Public' || row.paramRecordSecretLevelId === 'ID_PSL_Secret'
        case 'ID_PSL_Public':
          return row.paramRecordSecretLevelId === 'ID_PSL_Public'
        default:
          return false
      }
    }
  }
}
</script>

<style lang="less" scoped>

</style>
